# -*-coding:utf-8 -*-
"""
专题报表-沪深股票-沪深港通-沪深港通每日额度明细表
"""
from EmQuantAPI import *
import common.mainApi as mp
import common.handler_date_time as hd_dt
import common.handler_ctr_result as hd_cr
import common.dataFrame as df
import common.sql as db
import common.mainApi as ma
import config.base_info as bs

base_type = "ctr"
base_target = "target"
base_index = "DailyQuotaSHSZHKInfo"

info_ = bs.INDEX_INFO.get(base_type).get(base_target).get(base_index)  # ->dict
param_code = info_.get("return_data")  # ->list
param_ = ",".join(param_code)
option_ = "StartDate={0},EndDate={1}"


def mainDailyQuotaSHSZHKInfo(startDate="2021-03-22", endDate="2021-03-25"):

    data = c.ctr(base_index, param_, option_.format(startDate, endDate))

    return data


if __name__ == "__main__":
    mp.login()
    startDate = "2021-04-28"
    endDate = "2021-04-28"  
    # trade_date = hd_dt.getDateOfCycle(start_date=startDate, end_date=endDate)
    # for i in trade_date:
    data = mainDailyQuotaSHSZHKInfo(startDate=startDate, endDate=endDate)
    hd_cr.ctr_result_handler(data_res=data, index_=base_index)
    mp.stop()
    db.dbcon_dispose()  # close-db
